package moonlit.chill.pay.vo;

import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import moonlit.chill.pay.constants.Constants;

import java.io.Serializable;

/**
 * @author MoonlitChill
 * @date 2024/4/15 15:02
 */
@Data
@Slf4j
public class PayResult<T> implements Serializable {

    private static final long serialVersionUID = 1L;

    private T result;

    private boolean isSuccess = Boolean.FALSE;

    private String message = "ok";

    private Integer code = Constants.PAY_SUCCESS_CODE;

    private Exception exception;

    private String transNum;

    private String dataForCallback;

    private boolean sync = Boolean.FALSE;

    private boolean needFlow = Boolean.TRUE;

    public void error(String message, Integer code) {
        this.message = message;
        this.code = code;
        this.isSuccess = Boolean.FALSE;
    }

    public void errorWithException(String message, Integer code, Exception e) {
        this.message = message;
        this.code = code;
        this.exception = e;
        this.isSuccess = Boolean.FALSE;
        log.error("支付异常", e);
    }
}
